<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PostController extends Controller
{
    //
    public function show($post)
    {
        //    用数组创建模拟记录
        $posts = [
            'my-first-post' => 'foo',
            'my-second-post' => 'bar',
        ];
//    判断记录不存在的判断
        if (!array_key_exists($post, $posts)) {
            abort(404);
        }

//     用view来展现相应的记录
        return view('post', ['post' => $posts[$post]]);
        return $posts[$post];

    }
}
